Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zad 5 #133

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Zad 5 #133

wants to merge 15 commits into from

Conversation

WojciechKrzywda
Copy link

@WojciechKrzywda WojciechKrzywda commented Apr 16, 2019

Zrobione zadanie 5.

@WojciechKrzywda WojciechKrzywda changed the title Zrobione zadanie 5. Zad 5 Apr 16, 2019

day_req = 10
@building.warriors.each do |warrior|
day_req += if warrior.type == 'Warriors::Hussar'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ładniej by to chyba wyglądało, jeśli Warrior miałby zaimplementowaną metodę/atrybut np. supply_burn_rate, który zwraca 1 jeśli warrior nie ma konia i 2 jeśli go ma, wtedy nie trzeba by myśleć nad takimi ifami w tym serwisie :)

attr_reader :building

def calc_siege_ability
return 0 if @building.warriors.count.zero?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To sprawdzenie spokojnie by się mogło znaleźć gdzieś wyżej, żeby nie obciążać logiki serwisu :) Serwis najlepiej jeśli ma jedną odpowiedzialność, a Twój serwis poza liczeniem ile dni przetrwa dany budynek, stwierdza upadłość budynku jeśli nie ma w nim wojowników :)

end

it 'includes correct number of records' do
get '/buildings'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ten get też mógłby się znaleźć w before

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants